package com.youlai.boot.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.youlai.boot.common.result.PageResult;
import com.youlai.boot.common.result.Result;
import com.youlai.boot.system.model.dto.AuditRequestDTO;
import com.youlai.boot.system.model.query.RecycleRequestQuery;
import com.youlai.boot.system.model.vo.RecycleRequestVO;
import com.youlai.boot.system.model.vo.ValueLabelVO;
import com.youlai.boot.system.service.RequestManagerService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 张雨润
 * @date 2025/2/25 21:22
 * @Description
 */
@Tag(name = "申请管理")
@RestController
@RequestMapping("/api/v1/request-manager")
@RequiredArgsConstructor
public class RecycleManagerController {
    private final RequestManagerService requestManagerService;
    /**
     * （机构）查询管理申请回收分页数据
     * @param queryParams
     * @return
     */
    @PostMapping("/page/org")
    public PageResult<RecycleRequestVO> getRecycleRequestPageOrg(@RequestBody RecycleRequestQuery queryParams) {
        IPage<RecycleRequestVO> page = requestManagerService.getPage(queryParams);
        return PageResult.success(page);
    }

    /**
     * （机构）审核用户申请
     * @param auditRequestDTO
     * @return
     */
    @PostMapping("/audit")
    public Result<Boolean> auditRecycleRequest(@RequestBody AuditRequestDTO auditRequestDTO) {
        Boolean rs = requestManagerService.auditRecycleRequest(auditRequestDTO);
        return Result.success(rs);
    }


    /**
     * 查询隶属本机构的工作人员
     * @return
     */
    @GetMapping("/org/workers")
    public Result<List<ValueLabelVO>> getOrgWorkers(){
        return Result.success(requestManagerService.getOrgWorkers());
    }
}
